package com.ag.zrt.service.impl;

import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.ag.bean.TbEvent;
import com.ag.bean.TbEventPlanStart;
import com.ag.common.DateUtil;
import com.ag.wsq.dao.UserDAO;
import com.ag.wzp.dao.WzpTbEventDAO;
import com.ag.zhh.dao.ZHHEventPlanDAO;
import com.ag.zrt.dao.TbCurrentEventDAO;
import com.ag.zrt.dao.TbProposeDAO;
import com.ag.zrt.dao.ZRTEventPlanStartDAO;
import com.ag.zrt.service.IShowEventDetailService;

@Service("ShowEventDetailService")
public class ShowEventDetailService implements IShowEventDetailService {
	@Resource(name = "userDAO")
	private UserDAO userDAO;
	@Resource(name = "ZRTTbCurrentEventDAO")
	private TbCurrentEventDAO currentEventDAO;
	@Resource(name = "WzpTbEventDAO")
	private WzpTbEventDAO eventDAO;
	@Resource(name = "ZHHEventPlanDAO")
	private ZHHEventPlanDAO eventPlanDAO;
	@Resource(name = "ZRTTbProposeDAO")
	private TbProposeDAO proposeDAO;
	@Resource(name = "ZRTEventPlanStartDAO")
	private ZRTEventPlanStartDAO eventPlanStartDAO;

	public void setEventPlanStartDAO(ZRTEventPlanStartDAO eventPlanStartDAO) {
		this.eventPlanStartDAO = eventPlanStartDAO;
	}

	public void setProposeDAO(TbProposeDAO proposeDAO) {
		this.proposeDAO = proposeDAO;
	}

	public void setEventPlanDAO(ZHHEventPlanDAO eventPlanDAO) {
		this.eventPlanDAO = eventPlanDAO;
	}

	public void setEventDAO(WzpTbEventDAO eventDAO) {
		this.eventDAO = eventDAO;
	}

	public void setCurrentEventDAO(TbCurrentEventDAO currentEventDAO) {
		this.currentEventDAO = currentEventDAO;
	}

	public void setUserDAO(UserDAO userDAO) {
		this.userDAO = userDAO;
	}

	@Override
	public String findUserById(String id) {
		// TODO Auto-generated method stub
		return userDAO.findById(id).getUName();
	}

	@Override
	public String findUserId(String eventId) {
		// TODO Auto-generated method stub

		return currentEventDAO.findById(eventId).getEAdmin();
	}

	@Override
	public String findUserName(String eventId) {
		// TODO Auto-generated method stub

		return findUserById(findUserId(eventId));
	}

	@Override
	public TbEvent findEventById(String eventId) {
		// TODO Auto-generated method stub
		return eventDAO.findById(eventId);
	}

	@Override
	public String findEventName(String eventId) {
		// TODO Auto-generated method stub
		return findEventById(eventId).getEEventname();
	}

	@Override
	public String findPlanName(String eventId) {
		// TODO Auto-generated method stub
		if (eventPlanDAO.findPlanByEId(eventId) != null) {
			return eventPlanDAO.findPlanByEId(eventId).getPName();
		}
		return null;
	}

	@Override
	public String findHappenedTime(String eventId) {
		// TODO Auto-generated method stub
		Date happenedTime = findEventById(eventId).getEEventtime();

		return DateUtil.DateToString(happenedTime);
	}

	@Override
	public String findEventLevel(String eventId) {
		// TODO Auto-generated method stub
		if (eventDAO.findById(eventId).getTbEventLevel() != null)
			return eventDAO.findById(eventId).getTbEventLevel()
					.getElEventLevel();
		return null;
	}

	@Override
	public String findEventType(String eventId) {
		// TODO Auto-generated method stub
		if (eventDAO.findById(eventId).getTbEventType() != null)
			return eventDAO.findById(eventId).getTbEventType().getEtEventType();
		return null;
	}

	@Override
	public String findAssistDept(String eventId) {
		// TODO Auto-generated method stub
		if (proposeDAO.findProposeByEventId(eventId)
				.getTbUserDeptByPAssistDept() != null)
			return proposeDAO.findProposeByEventId(eventId)
					.getTbUserDeptByPAssistDept().getUdName();
		return null;
	}

	@Override
	public String findCommander(String eventId) {
		// TODO Auto-generated method stub
		if (proposeDAO.findProposeByEventId(eventId).getTbUserByPCommander() != null)
			return proposeDAO.findProposeByEventId(eventId)
					.getTbUserByPCommander().getUName();
		return null;
	}

	/*
	 * Old
	 * 
	 * @see
	 * com.ag.zrt.service.IShowEventDetailService#findImplementPlan(java.lang
	 * .String)
	 */
	// @Override
	// public String findImplementPlan(String eventId) {
	// // TODO Auto-generated method stub
	// if (proposeDAO.findProposeByEventId(eventId)
	// .getTbUserDeptByPImplementPlan() != null)
	// return proposeDAO.findProposeByEventId(eventId)
	// .getTbUserDeptByPImplementPlan().getUdName();
	// return null;
	// }

	@Override
	public String findImplementPlan(String eventId) {
		// TODO Auto-generated method stub
		if (proposeDAO.findProposeByEventId(eventId) != null)
			return proposeDAO.findProposeByEventId(eventId).getE();
		return null;
	}

	@Override
	public String findTeamLeader(String eventId) {
		// TODO Auto-generated method stub
		if (proposeDAO.findProposeByEventId(eventId).getTbUserByPTeamLeader() != null)
			return proposeDAO.findProposeByEventId(eventId)
					.getTbUserByPTeamLeader().getUName();
		return null;
	}

	@Override
	public String findViceCommander(String eventId) {
		// TODO Auto-generated method stub
		if (proposeDAO.findProposeByEventId(eventId)
				.getTbUserByPViceCommander() != null)
			return proposeDAO.findProposeByEventId(eventId)
					.getTbUserByPViceCommander().getUName();
		return null;
	}

	@Override
	public String asianGames(String eventId) {
		// TODO Auto-generated method stub
		return proposeDAO.findProposeByEventId(eventId).getPAsianGames();
	}

	@Override
	public String bureau(String eventId) {
		// TODO Auto-generated method stub
		return proposeDAO.findProposeByEventId(eventId).getPBureau();
	}

	@Override
	public String emergency(String eventId) {
		// TODO Auto-generated method stub
		return proposeDAO.findProposeByEventId(eventId).getPEmergency();
	}

	@Override
	public String government(String eventId) {
		// TODO Auto-generated method stub
		return proposeDAO.findProposeByEventId(eventId).getPGovernment();
	}

	@Override
	public String release(String eventId) {
		// TODO Auto-generated method stub
		return proposeDAO.findProposeByEventId(eventId).getPRelease();
	}

	@Override
	public String findAcceptTime(String eventId) {
		// TODO Auto-generated method stub
		Date acceptTime = eventDAO.findById(eventId).getEAcceptTime();
		return DateUtil.DateToString(acceptTime);
	}

	@Override
	public String findAccepter(String eventId) {
		// TODO Auto-generated method stub
		if (eventDAO.findById(eventId).getTbUserByUId() != null) {
			return eventDAO.findById(eventId).getTbUserByUId().getUName();
		}
		return null;
	}

	@Override
	public String findCause(String eventId) {
		// TODO Auto-generated method stub
		return eventDAO.findById(eventId).getEEventCause();
	}

	@Override
	public int findDeath(String eventId) {
		// TODO Auto-generated method stub
		if (eventDAO.findById(eventId).getEDeaths() != null) {
			return eventDAO.findById(eventId).getEDeaths();
		}
		return 0;
	}

	@Override
	public String findEventDesc(String eventId) {
		// TODO Auto-generated method stub
		return eventDAO.findById(eventId).getEEventDesc();
	}

	@Override
	public int findInjured(String eventId) {
		// TODO Auto-generated method stub
		if (eventDAO.findById(eventId).getEInjuries() != null) {
			return eventDAO.findById(eventId).getEInjuries();
		}
		return 0;
	}

	@Override
	public String findMeasure(String eventId) {
		// TODO Auto-generated method stub
		return eventDAO.findById(eventId).getETakeMeasure();
	}

	@Override
	public String findPlace(String eventId) {
		// TODO Auto-generated method stub
		return eventDAO.findById(eventId).getEEventAddr();
	}

	@Override
	public String findSource(String eventId) {
		// TODO Auto-generated method stub
		if (eventDAO.findById(eventId).getTbEventSource() != null) {
			return eventDAO.findById(eventId).getTbEventSource()
					.getEsEventSource();
		}
		return null;
	}

	@Override
	public String findSubmitDept(String eventId) {
		// TODO Auto-generated method stub
		return eventDAO.findById(eventId).getESubmitDept();
	}

	@Override
	public String findSubmiter(String eventId) {
		// TODO Auto-generated method stub
		return eventDAO.findById(eventId).getESubmiter();
	}

	@Override
	public String findSubmitTime(String eventId) {
		// TODO Auto-generated method stub
		Date sumitTime = eventDAO.findById(eventId).getESubmitTime();
		return DateUtil.DateToString(sumitTime);
	}

	@Override
	public String findSubmiterContact(String eventId) {
		// TODO Auto-generated method stub
		return eventDAO.findById(eventId).getESubmiterContact();
	}

	@Override
	public String findContent(String eventId) {
		// TODO Auto-generated method stub
		return proposeDAO.findProposeByEventId(eventId).getPaContent();
	}

	@Override
	public String findLeaderSuggestion(String eventId) {
		// TODO Auto-generated method stub
		return proposeDAO.findProposeByEventId(eventId).getPLeaderComments();
	}

	@Override
	public String findTime(String eventId) {
		// TODO Auto-generated method stub
		Date time = proposeDAO.findProposeByEventId(eventId).getPaTime();
		return DateUtil.DateToString(time);
	}

	@Override
	public String findEventStatus(String eventId) {
		// TODO Auto-generated method stub
		if (eventDAO.findById(eventId).getTbEventStatus() != null) {
			return eventDAO.findById(eventId).getTbEventStatus()
					.getTbesEventStatus();
		}
		return null;
	}

	@Override
	public List<TbEventPlanStart> findPlanStanderd(String eventId) {
		// TODO Auto-generated method stub
		if (eventPlanStartDAO.findByEventId(eventId) != null) {
			return eventPlanStartDAO.findByEventId(eventId);
		}
		return null;
	}

	@Override
	public String findAssistDeptDId(String eventId) {
		// TODO Auto-generated method stub
		if (proposeDAO.findProposeByEventId(eventId)
				.getTbUserDeptByPAssistDept() != null)
			return proposeDAO.findProposeByEventId(eventId)
					.getTbUserDeptByPAssistDept().getUdId();
		return null;
	}

	@Override
	public String findCommanderUId(String eventId) {
		// TODO Auto-generated method stub
		if (proposeDAO.findProposeByEventId(eventId).getTbUserByPCommander() != null)
			return proposeDAO.findProposeByEventId(eventId)
					.getTbUserByPCommander().getUId();
		return null;
	}

	@Override
	public String findTeamLeaderUId(String eventId) {
		// TODO Auto-generated method stub
		if (proposeDAO.findProposeByEventId(eventId).getTbUserByPTeamLeader() != null)
			return proposeDAO.findProposeByEventId(eventId)
					.getTbUserByPTeamLeader().getUId();
		return null;
	}

	@Override
	public String findViceCommanderUId(String eventId) {
		// TODO Auto-generated method stub
		if (proposeDAO.findProposeByEventId(eventId)
				.getTbUserByPViceCommander() != null)
			return proposeDAO.findProposeByEventId(eventId)
					.getTbUserByPViceCommander().getUId();
		return null;
	}

	@Override
	public String findCurRole(String eventId) {
		// TODO Auto-generated method stub
		if (proposeDAO.findProposeByEventId(eventId) != null)
			return proposeDAO.findProposeByEventId(eventId).getF();
		return null;
	}
}
